<template>
  <div>
    <Header></Header>
    <div style="background:#f6f6f6;width:100%;height:30px;"></div>
    <div class="classification">
      <div class="left">
        <div class="left-h">
          <p>运营推广</p>
        </div>
        <div class="left-f" v-for="(item,index) in articleList" :key="index">
          <div class="content-left">
            <img :src="item.cover" alt>
          </div>
          <div class="content-right">
            <h1>{{item.title}}</h1>
            <div class="content" @click="getArticle(item)">{{item.content}}</div>
            <div class="tags">
              <span>
                <img src="../../assets/images/logo.jpg" alt>
              </span>
              <span style="padding-left:10px;">{{item.nickname}}</span>
              <img :src="item.avatar" alt class="img">
              <span>{{item.add_time}}</span>
              <span style="padding-left:40%;">
                <i class="iconfont icon-all-shoucang3"></i>
                208
              </span>
              <span>
                <i class="iconfont icon-all-like"></i>
                {{item.supports}}
              </span>
            </div>
          </div>
        </div>
        <div class="more" @click="getMore">
          <span>加载更多</span>
        </div>
      </div>
      <div class="right">
        <img src="../../assets/images/card.jpg" alt>
        <img src="../../assets/images/card.jpg" alt>
        <div class="right-tags">
          <div class="tags-title">
            <P>热门标签</P>
          </div>
          <div class="tags-content">
            <div>
              <span>配置信</span>
              <span>配置信</span>
              <span>配置信</span>
              <span>配置信</span>
              <span>配置信</span>
              <span>配置信</span>
              <span>配置信</span>
              <span>配置信</span>
              <span>配置信</span>
            </div>
          </div>
        </div>
        <div class="tags-list">
          <div class="box">2019年十大营销关键词</div>
          <div class="list-title">
            <P>热门文章</P>
          </div>
          <img src="../../assets/images/card.jpg" alt>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Header from "@/common/Header/Header";
export default {
  name: "classification",
  data() {
    return {
      sizeIndex: 10,
      id: "",
      articleList: [],
      article_id:'',
    };
  },
  methods: {
    //获取文章的数据id
    getArticle(item) {
      console.log(item.id)
      // return;
      // this.$router.push("/article");
      this.$router.push({path:"/article",query:{article_id:item.id}});
    },
    //获取分类ID
    getmessage() {
      this.id = this.$route.query.infoId;
      console.log(this.id);
    },
    //获取文章列表
    getAllList() {
      this.$axios
        .get(
          "api/App/User/News/get_list?new_category_id=" +
            this.id +
            "&p=1&limit=" +
            this.sizeIndex,
          {}
        )
        .then(res => {
          this.articleList = res.data.data.list;
          // console.log(this.articleList);
        });
    },
    //加载更多的文章
    getMore(){
      this.sizeIndex=this.sizeIndex+10;
      console.log(this.sizeIndex)
      // return;
      this.$axios
        .get(
          "api/App/User/News/get_list?new_category_id=" +
            this.id +
            "&p=1&limit=" +
            this.sizeIndex,
          {}
        )
        .then(res => {
          this.articleList = res.data.data.list;
          console.log(this.articleList);
        });
    },
  },

  components: {
    Header
  },
  created() {
    this.getmessage();
    this.getAllList();
  }
};
</script>
<style lang="scss" scoped>
.classification {
  width: 1170px;
  height: auto;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  margin-bottom: 30px;
  .left {
    width: 810px;
    background: #f5f5f5;
    .left-h {
      width: 95%;
      height: 50px;
      margin: 0 auto;
      position: relative;
      p {
        position: absolute;
        left: 0;
        bottom: -18px;
        font-size: 18px;
        border-bottom: 3px solid #5b90bc;
      }
    }
    .left-f {
      width: 95%;
      margin: 0 auto;
      display: flex;
      justify-content: space-between;
      border-top: 1px solid #f0f0f0;
      height: 190px;
      .content-left {
        width: 30%;
        height: 150px;
        margin-top: 20px;
        img {
          display: block;
          width: 100%;
          height: 150px;
          border-radius: 10px;
        }
      }
      .content-right {
        width: 68%;
        height: 160px;
        margin-top: 20px;
        h1 {
          font-size: 16px;
          font-weight: 900;
          text-align: left;
        }
        .content {
          text-align: left;
          font-size: 12px;
          margin-top: 10px;
          line-height: 2;
        }
        .tags {
          text-align: left;
          margin-top: 10px;
          .img {
            width: 10px;
            height: 10px;
          }
          span {
            font-size: 12px;
            color: #b9b9b9;
            img {
              width: 30px;
              height: 30px;
              border-radius: 50%;
            }
          }
        }
      }
    }
    .more {
      width: 100%;
      height: 60px;
      margin-bottom: 20px;
      display: flex;
      align-items: center;
      span {
        display: block;
        width: 100px;
        height: 30px;
        line-height: 30px;
        margin: 0 auto;
        background: #aed6ff;
        border-radius: 5px;
        cursor: pointer;
        color: #fff;
      }
    }
  }
  .right {
    width: 330px;
    img {
      display: block;
      width: 100%;
      height: 130px;
      border-radius: 10px;
      margin-bottom: 40px;
    }
    .right-tags {
      background: #fff;
      width: 100%;
      height: 220px;
      .tags-title {
        width: 90%;
        height: 50px;
        margin: 0 auto;
        position: relative;
        border-bottom: 2px solid #f8f8f8;
        p {
          position: absolute;
          left: 0;
          bottom: -18px;
          font-size: 18px;
          border-bottom: 2px solid #5b90bc;
        }
      }
      .tags-content {
        width: 170px;
        width: 90%;
        margin: 0 auto;
        margin-top: 10px;
        div {
          width: 80%;
          padding-left: 20px;
          span {
            display: inline-block;
            width: 60px;
            height: 20px;
            border-radius: 10px;
            font-size: 10px;
            color: #ddd;
            border: 1px solid #ddd;
            margin-bottom: 20px;
          }
        }
      }
    }
    .tags-list {
      background: #f5f5f5;
      width: 100%;
      margin-top: 30px;
      height: 200px;
      position: relative;
      .box {
        height: 50px;
        width: 90%;
        position: absolute;
        bottom: -10px;
        left: 5%;
        color: #f5f5f5;
        background: #000;
        opacity: 0.5;
        border-radius: 0px 0px 10px 10px;
        line-height: 50px;
        font-size: 18px;
        padding-right: 80px;
      }
      .list-title {
        width: 90%;
        height: 50px;
        margin: 0 auto;
        position: relative;
        border-bottom: 2px solid #f0f0f0;
        p {
          position: absolute;
          left: 0;
          bottom: -18px;
          font-size: 18px;
          border-bottom: 2px solid #5b90bc;
        }
      }
      img {
        display: block;
        width: 90%;
        margin: 0 auto;
        height: 150px;
        border-radius: 10px;
        margin-top: 10px;
      }
    }
  }
}
</style>


